/**
*  Author: Magnus Hemmer Pihl
*  Student number: 5452
*
*  Assignment 1, part 1
**/

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	short numRooms = 0;		//Number of rooms in the house. Set by the user.
	cout << "Enter number of rooms in the house: ";
	cin >> numRooms;
	cout << "\n";
	//Make sure the user entered at least 1 room...
	if(numRooms < 1)
	{
		cout << "Can't have a house with no rooms, nub.\n";
		system("PAUSE");
		return 0;
	}

	//Create array (static size) containing sizes of each room in the house.
	double *roomSize;
	roomSize = new double[numRooms];
	double totalSize = 0.0;		//Keep track of the total size of the house...
	short largestRoom = 0;		//... the index of the largest room in the house...
	short smallestRoom = 0;		//... and the index of the smallest room.
	//Run the loop asking for the size for each room
	for(int i=0; i<numRooms; i++)
	{
		cout << "Enter size (square meters) of room " << i+1 << ": ";
		cin >> roomSize[i];
		//Update total size and smallest/largest index as necessary
		totalSize += roomSize[i];
		if(roomSize[i] < roomSize[smallestRoom])
			smallestRoom = i;
		if(roomSize[i] > roomSize[largestRoom])
			largestRoom = i;
	}
	cout << "\n";
	cout << "Total size of house: " << totalSize << "m^2.\n";
	cout << "Smallest room in the house: " << smallestRoom+1 << ".\n";
	cout << "Largest room in the house: " << largestRoom+1 << ".\n";
	cout << "Mean size of rooms in the house: " << totalSize/numRooms << ".\n";

	system("PAUSE");
	return 0;
}